package org.linlinjava.litemall.admin.config;

import lombok.Data;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.springframework.stereotype.Component;

import java.io.Serializable;
@Component
@Data
public class AdminAccountToken extends UsernamePasswordToken implements Serializable {

    private String username;

    private String pwd;


    //无参构造
    public AdminAccountToken(){}



    //获取存入的值
    @Override
    public Object getPrincipal() {
        if (username == null) {
            return getUsername();
        } else {
            return getUsername();
        }
    }

    @Override
    public Object getCredentials() {
        if (pwd == null) {
            return getPassword();
        }else {
            return "ok";
        }

    }

    public AdminAccountToken(String username,String pwd) {
        this.username = username;
        this.pwd = pwd;
    }

}
